<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>智能体问答系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
</head>
<body>
    <div class="container-fluid h-100">
        <!-- 头部 -->
        <header class="row bg-primary text-white py-3">
            <div class="col">
                <h1 class="h3 mb-0">
                    <i class="bi bi-robot"></i> 智能体问答系统
                </h1>
                <small>基于思维链的智能问答平台</small>
            </div>
            <div class="col-auto">
                <div class="d-flex align-items-center">
                    <span class="badge bg-success me-2" id="connection-status">已连接</span>
                    <button class="btn btn-outline-light btn-sm" onclick="clearSession()">
                        <i class="bi bi-arrow-clockwise"></i> 新会话
                    </button>
                </div>
            </div>
        </header>

        <!-- 主内容区域 -->
        <div class="row flex-grow-1" style="height: calc(100vh - 100px);">
            <!-- 对话区域 -->
            <div class="col-8 d-flex flex-column">
                <div class="card h-100">
                    <div class="card-header bg-light">
                        <h5 class="mb-0">
                            <i class="bi bi-chat-dots"></i> 问答对话
                        </h5>
                    </div>
                    <div class="card-body flex-grow-1 overflow-auto" id="chat-container">
                        <div class="text-center text-muted py-5">
                            <i class="bi bi-chat-square-text display-4"></i>
                            <p class="mt-3">请输入您的问题开始对话</p>
                        </div>
                    </div>
                    <!-- 输入区域 -->
                    <div class="card-footer">
                        <div class="input-group">
                            <textarea class="form-control" id="question-input" 
                                     placeholder="在这里输入你的问题..." 
                                     rows="2" style="resize: none;"></textarea>
                            <button class="btn btn-primary" id="send-btn" onclick="sendQuestion()">
                                <i class="bi bi-send"></i> 发送
                            </button>
                        </div>
                        <div class="form-text mt-2">
                            <span class="text-muted">按 Ctrl+Enter 快速发送</span>
                            <span class="float-end" id="typing-indicator" style="display: none;">
                                <i class="bi bi-three-dots text-primary"></i> AI正在思考...
                            </span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 任务列表区域 -->
            <div class="col-4 d-flex flex-column">
                <div class="card h-100">
                    <div class="card-header bg-light d-flex justify-content-between align-items-center">
                        <h5 class="mb-0">
                            <i class="bi bi-list-task"></i> 任务列表
                        </h5>
                        <div class="d-flex align-items-center">
                            <small class="text-muted me-2" id="task-progress">0/0</small>
                            <div class="progress me-2" style="width: 100px; height: 6px;">
                                <div class="progress-bar" id="progress-bar" style="width: 0%"></div>
                            </div>
                        </div>
                    </div>
                    <div class="card-body flex-grow-1 overflow-auto" id="task-container">
                        <div class="text-center text-muted py-5">
                            <i class="bi bi-clipboard-check display-4"></i>
                            <p class="mt-3">暂无任务</p>
                        </div>
                    </div>
                    <!-- 执行控制 -->
                    <div class="card-footer" id="execution-controls" style="display: none;">
                        <div class="d-grid gap-2">
                            <button class="btn btn-success" id="start-execution-btn" onclick="startExecution()">
                                <i class="bi bi-play-circle"></i> 开始执行
                            </button>
                            <button class="btn btn-danger" id="cancel-execution-btn" onclick="cancelExecution()" style="display: none;">
                                <i class="bi bi-stop-circle"></i> 取消执行
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 任务编辑模态框 -->
    <div class="modal fade" id="taskEditModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">修改任务</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="mb-3">
                        <label class="form-label">任务描述</label>
                        <textarea class="form-control" id="task-edit-description" rows="3"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveTaskEdit()">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 脚本 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
    <script src="{{ url_for('static', filename='js/app.js') }}"></script>
</body>
</html>